import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AuthService } from '@core/public/auth/auth.service';

// @ts-ignore
import { LayoutDefaultComponent } from '@layout/default/default.component';
import { FirstPageComponent } from './pages/first-page/first-page.component';

import { SystemMsgComponent } from '@core/baseModule/system-msg/system-msg.component';
import { RoleMagComponent } from '@core/baseModule/role-mag/role-mag.component';
import { UserMagComponent } from '@core/baseModule/user-mag/user-mag.component';
import { MenusComponent } from '@core/baseModule/menus/menus.component';
import { TestComponent } from './pages/test/test.component';
import { TestModComponent } from './pages/test/test-mod/test-mod.component';
import { TestListComponent } from './pages/test/test-list/test-list.component';

const routes: Routes = [
  {
    path: '',
    component: LayoutDefaultComponent,
    children: [
      { path: '', redirectTo: '/firstPage', pathMatch: 'full' },
      {
        path: 'firstPage',
        component: FirstPageComponent,
        data: {
          breadcrumb: '首页'
        }
      },
      {
        path: 'systemMsg',
        component: SystemMsgComponent,
        data: {
          breadcrumb: '系统信息'
        },
        canActivate: [AuthService]
      },
      {
        path: 'RoleMag',
        component: RoleMagComponent,
        data: {
          breadcrumb: '角色管理'
        },
        canActivate: [AuthService]
      },
      {
        path: 'UserMag',
        component: UserMagComponent,
        data: {
          breadcrumb: '用户管理'
        },
        canActivate: [AuthService]
      },
      {
        path: 'personCenter',
        data: {
          breadcrumb: '个人中心'
        },
        canActivate: [AuthService],
        loadChildren:
          '@core/baseModule/person-center/personCenter.module#PersonCenterModule'
      },
      {
        path: 'menus',
        component: MenusComponent,
        data: {
          breadcrumb: '菜单配置'
        },
        canActivate: [AuthService]
      },
      {
        path: 'organicStucture',
        canActivate: [AuthService],
        loadChildren:
          '@core/baseModule/departments/departments.module#DepartmentsModule'
      },
      {
        path: 'staff',
        canActivate: [AuthService],
        loadChildren:
          '@core/baseModule/staffs/staffs.module#StaffsModule'
      },
      {
        path: 'test',
        component: TestComponent,
        data: {
          breadcrumb: '测试'
        },
        canActivate: [AuthService],
        children: [
          { path: '', redirectTo: 'testList', pathMatch: 'full' },
          {
            path: 'testList',
            component: TestListComponent,
          },
          {
            path: 'testMod',
            component: TestModComponent,
          }
        ]
      },
    ]
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
      useHash: true,
      // NOTICE: If you use `reuse-tab` component and turn on keepingScroll you can set to `disabled`
      // Pls refer to https://ng-alain.com/components/reuse-tab
      scrollPositionRestoration: 'top'
    })
  ],
  exports: [RouterModule]
})
export class AppRoutingModule {}
